// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr;
// import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.Collections;
// import java.util.List;

#include "OracleBinaryFloatExpr.h"
#include "../../../../ast/SQLObject.h"
#include "../../visitor/OracleASTVisitor.h"
#include "../../../../visitor/SQLASTVisitor.h"
#include "../../../../../utils/doubleEqual.h"

OracleBinaryFloatExpr::OracleBinaryFloatExpr()
{
}

OracleBinaryFloatExpr::OracleBinaryFloatExpr(float value)
    : SQLNumericLiteralExpr()
{

  this->value = value;
}

SQLObject_ptr OracleBinaryFloatExpr::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<OracleBinaryFloatExpr>(new OracleBinaryFloatExpr(value));
  std::shared_ptr<OracleBinaryFloatExpr> x = std::dynamic_pointer_cast<OracleBinaryFloatExpr>(clone_tmp);
  return x;
}

// @Override
SQLObject_list_ptr OracleBinaryFloatExpr::getChildren()
{
  SQLObject_list_ptr tmp = std::make_shared<std::list<SQLObject_ptr>>();
  return tmp;
}

// @Override
double OracleBinaryFloatExpr::getNumber()
{
  return value;
}

float OracleBinaryFloatExpr::getValue()
{
  return value;
}

void OracleBinaryFloatExpr::setValue(float value)
{
  this->value = value;
}

// @Override
void OracleBinaryFloatExpr::accept0(SQLASTVisitor_ptr visitor)
{
  accept0(std::dynamic_pointer_cast<OracleASTVisitor>(visitor));
}

void OracleBinaryFloatExpr::accept0(OracleASTVisitor_ptr visitor)
{
  visitor->visit(SharedObject(OracleBinaryFloatExpr));
  visitor->endVisit(SharedObject(OracleBinaryFloatExpr));
}

// @Override
int OracleBinaryFloatExpr::hashCode()
{
  int prime = 31;
  int result = 1;
  // result = prime * result + ((value == nullptr) ? 0 : value.hashCode());
  result = prime * result + (int)value;
  return result;
}

// @Override
bool OracleBinaryFloatExpr::equals(Object_ptr obj)
{
  if (this == obj.get())
  {
    return true;
  }
  if (obj == nullptr)
  {
    return false;
  }
  if (getClass()->c_str() != obj->getClass()->c_str())
  {
    return false;
  }
  OracleBinaryFloatExpr_ptr other = std::dynamic_pointer_cast<OracleBinaryFloatExpr>(obj);
  // if (value == nullptr) {
  //     if (other.value != nullptr) {
  //         return BOOL::FALSE;
  //     }
  // } else if (!value.equals(other.value)) {
  //     return BOOL::FALSE;
  // }
  doubleEqual::AreEqual(value, other->value);
  return true;
}

// @Override
void OracleBinaryFloatExpr::setNumber(float number)
{
  // if (number == nullptr) {
  //     this->setValue(nullptr);
  //     return;
  // }

  this->setValue(number);
}
